<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php 
$RealOrderId = $this->getOrderId();
$orders = Mage::getSingleton('checkout/session')->getLastRealOrder();
$items = $orders->getAllItems();
?>
<div class="page-head">
    <h3><?php echo $this->__('Your payment is succeed!Your order has been received') ?></h3>
    <div class="success-msg" ><?php echo $_SESSION['payment_details'];?></div>
</div>

<?php if ($this->getOrderId()):?>
<?php if ($this->getCanViewOrder()) :?>
    <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
<?php  else :?>
    <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
<?php endif;?>
    <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
    <p class="text-order">
          <?php echo $this->__('Click ') ?>
          <?php echo $this->__('<a href="%s" onclick="this.target=\'_blank\'">', $this->getPrintUrl()) ?>
          <?php echo $this->__(' here to print </a>') ?>
          <?php echo $this->__('a copy of your order confirmation.') ?>
        <?php echo $this->getChildHtml() ?>
    </p>
<?php endif;?>
<?php endif;?>

<?php if ($this->getAgreementRefId()): ?>
    <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
<?php endif;?>

<?php if ($profiles = $this->getRecurringProfiles()):?>
<p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
<ul class="disc">
<?php foreach($profiles as $profile):?>
<?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
    <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
<?php endforeach;?>
</ul>
<?php endif;?>

<div class="buttons-set">
    <button type="button" class="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue Shopping')) ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
</div>

<script>
//wang google
   ga('set', '&cu', '<?php echo $orders->getBaseCurrencyCode()?>');
	<?php foreach ($items as $_item){
	    if ($_item->getParentItem()) continue;
	    ?>
    ga('ec:addProduct', {
      'id': "<?php echo $_item->getSku();?>",
      'name': '<?php echo addslashes($_item->getName());?>',
      'category': "",
      'brand': '<?php echo $_item->getCommonBrand();?>',
      'variant':  '',
      'price': '<?php echo $_item->getPrice();?>',
      'quantity': '<?php echo $_item->getQty();?>'
    });
    <?php }?>
	// Transaction level information is provided via an actionFieldObject.
	ga('ec:setAction', 'purchase', {
	  'id': "<?php echo $RealOrderId?>",
	  'affiliation': 'rumall Store - Online',
	  'revenue': "<?php echo $orders->getBaseSubtotal()?>",
	  'tax': "<?php echo $orders->getBaseTaxAmount() ?>",
	  'shipping': "<?php echo $orders->getBaseShippingAmount()?>",
	  'coupon': "<?php echo $orders->getBaseCouponCode() ?>"    // User added a coupon at checkout.
	});

	ga('send', 'pageview');  
 </script>
<!-- Facebook Pixel Code -->
 <script type="text/javascript">
   //fbq('track', 'Purchase', {
   // content_type: 'product', //either 'product' or 'product_group'
   // content_ids: [<?php foreach ($items as $_item){if ($_item->getParentItem()) continue;echo "'".$_item->getSku()."',";}?>], //array of one or more product ids in the page
   // value: <?php echo $orders->getBaseSubtotal()?>, //REQUIRED
  //  currency: 'USD' //REQUIRED
//});
 dataLayer.push({
	    "ecommerce": {
	        "purchase": {
	            "actionField": {
	                "id" : '<?php echo $RealOrderId?>',
	            },
	            "products": [
<?php foreach ($items as $_item){
    if ($_item->getParentItem()) continue;
    ?>
	                {
	                    "id": "<?php echo $_item->getSku();?>",
	                    "name": '<?php echo addslashes($_item->getName());?>',
	                    "price": '<?php echo $_item->getPrice();?>',
	                    "brand": '<?php echo $_item->getCommonBrand();?>',
	                    "quantity":'<?php echo $_item->getQty();?>',
	                },
  <?php }?>
	            ]
	        }
	    }
	});
 </script>